<template>
    <section class="toast-container">
        <div class="toast" :class="[visible?'fade-in':'fade-out']">
            <span>{{message}}</span>
        </div>
    </section>
</template>
<style>
    /*定义动画淡入*/
    @keyframes fade-in {
        0% {
            /*透明度*/
            opacity: 0;
            /*动作*/
            transform: scale(0.7);
        }
        100% {
            opacity: 1;
            transform:scale(1);
        }
    }
    /*定义动画淡出*/
    @keyframes fade-out {
        0% {
            /*透明度*/
            opacity: 1;
            /*动作*/
            transform: scale(1);
        }
        100% {
            opacity: 0;
            transform:scale(0.7);
        }
    }

    .toast-container{
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 2000;
        display: flex;
        /*水平居中*/
        justify-content: center;
        /*垂直居中*/
        align-items: center;
    }
    .toast{
        width: 180px;
        height: 60px;
        line-height: 60px;
        text-align: center;
        background: rgba(0,0,0,0.61);
        border-radius: 10px;
        color: white;
    }

    .fade-in {
        /*动画调用名称*/
        animation-name: fade-in;
        /*动画持续时间*/
        animation-direction: 0.3s;
        animation-fill-mode: both;
    }
    .fade-out {
        /*动画调用名称*/
        animation-name: fade-out;
        /*动画持续时间*/
        animation-direction: 0.3s;
        animation-fill-mode: both;
    }
</style>
<script>
    export default {
        data(){
            return{
                message:'',
                visible:false
            }
        }
    }
</script>